package admincow.servlet.funcion;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import admincow.dao.FuncionDAO;
import admincow.vo.FuncionVO;


public class FuncionInsertarServlet extends javax.servlet.http.HttpServlet
		implements javax.servlet.Servlet {
	static final long serialVersionUID = 1L;


	public FuncionInsertarServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		// 
		String a = request.getParameter("funcion");
		System.out.println(a);
		/*String z = request.getParameter("pusuario");
		if(z.contentEquals("null")){
			z="0";
		}
		System.out.println(z);*/
		//System.out.println("hola");
		String b = request.getParameter("pusuario");
		if(b!=null){
			b="1";
		}else{
			b="0";
		}
		System.out.println(b);
		String c = request.getParameter("peventos");	
		if(c!=null){
			c="1";
		}else{
			c="0";
		}
		System.out.println(c);
		String d = request.getParameter("panimales");
		if(d!=null){
			d="1";
		}else{
			d="0";
		}
		System.out.println(d);
		String e = request.getParameter("pinseminacion");
		if(e!=null){
			e="1";
		}else{
			e="0";
		}
		System.out.println(e);
		String f = request.getParameter("pproduccion");
		if(f!=null){
			f="1";
		}else{
			f="0";
		}
		System.out.println(f);
		String g = request.getParameter("pfotos");
		if(g!=null){
			g="1";
		}else{
			g="0";
		}
		System.out.println(g);
		String h = request.getParameter("descripcion");
		System.out.println(h);

		
		FuncionVO vo = new FuncionVO();
		vo.setNom_fun(a);
		vo.setP_usuario(b);
		vo.setP_eventos(c);
		vo.setP_animales(d);
		vo.setP_inseminacion(e);
		vo.setP_produccion(f);
		vo.setP_fotos(g);
		vo.setDescripcion(h);
		
		FuncionDAO dao = new FuncionDAO();
		dao.insertar(vo);

		RequestDispatcher rd = request
				.getRequestDispatcher("/funcionBuscar.jsp");
		rd.forward(request, response);

	}
}